//1.安装mongoose
//2.导入mongo0se
const mongoose=require('mongoose');

//3.连接mongodb服务                           数据库
mongoose.connect('mongodb://127.0.0.1:27017/music');
//4.设置回调
mongoose.connection.on('open',()=>{
    console.log('连接成功');
});
mongoose.connection.on('close',()=>{
    console.log('连接关闭');
});
mongoose.connection.on('err',()=>{
    console.log('出错了');
});
// setTimeout(()=>{
// mongoose.disconnect();
// },2000)